﻿
@{
    ViewData["Title"] = "LogList";
    Layout = "~/Areas/Admin/Views/_Layout.cshtml";
}
<table class="layui-hide" id="tabledata" lay-filter="tabledata"></table>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        @Html.Raw(Mrc.Application.PermissionButtonHelper.CreateButtonHtml(new List<string> {"user.projectdemand.update", "user.projectdemand.delete" }, ViewContext.HttpContext));
        <button class="layui-btn layui-btn-sm layui-laypage-btn" onclick="javascript:location.replace(location.href);">刷新</button>
    </div>
</script>
<script type="text/html" id="operation">
    <a class="layui-btn layui-btn-xs" lay-event="addTask">添加任务</a>
    @*<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="lookDemand">查看需求</a>*@
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#tabledata'
                , height: 'full-20'
                , url: '/project/ProjectDemand/Models'
                , toolbar: '#toolbarDemo'
                , title: '需求'
                , cols: [[
                    { type: 'checkbox', fixed: 'left' }
                    , { field: 'name', title: '需求名称', fixed: 'left', unresize: false, sort: true }
                    , { field: 'projectName', title: '项目名称' }
                    , { field: 'executeUser', title: '执行人' }
                    , { field: 'endtime', title: '结束时间', sort: true }
                    , { field: 'type', title: '需求类型', sort: true }
                    , { field: 'priority', title: '优先级', sort: true }
                    , { field: 'status', title: '项目状态', sort: true }
                    , { field: 'description', title: '描述', sort: true }                   
                    , { field: '', title: '操作', templet:'#operation'}
                ]]
                , limits: [10, 15, 40, 60, 80,100,200,400]
                , limit: 100 //默认采用10
                , page: true
                , request: {
                    pageName: 'pageNumber' //页码的参数名称，默认：page
                    ,limitName: 'pageSize' //每页数据量的参数名，默认：limit
                }
            });

            //监听工具条
            table.on('tool(tabledata)',function (obj){
                var data = obj.data;
                if (obj.event === 'addTask') {
                    x_admin_show("添加任务", "/project/ProjectTask/add?Id=" + data.id, 777, 650);
                }
            });
            //头工具栏事件
            table.on('toolbar(tabledata)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'add':
                        var data = checkStatus.data;
                        if (data.length > 1)
                        {
                            layer.msg('请选择单个编辑项');
                            break;
                        }
                        else
                        {
                            var thisline = data[0];
                            var id = thisline.id;
                            x_admin_show("添加任务", "/project/ProjectTask/add?Id=" + id, 777, 650);
                        }
                        break;
                    case 'update':
                        var data = checkStatus.data;
                        if (data.length > 1)
                        {
                            layer.msg('请选择单个编辑项');
                            break;
                        }
                        else
                        {
                            var thisline = data[0];
                            var id = thisline.id;
                            x_admin_show("更新需求", "/project/ProjectDemand/update?Id=" + id, 777, 650);
                        }
                        break;
                };
            });
        });
</script>
